const promise1 = new Promise((resolve, reject) => {
    setTimeout(() => {
        resolve('success')
        console.log('time1');
    }, 1000)
})

const promise2 = promise1.then(() => {
    throw new Error('error') // 返回的promise对象的状态会是rejected
})

console.log('promise1', promise1);
console.log('promise2', promise2);

setTimeout(() => {
    console.log('time2');
    console.log('promise1', promise1);
    console.log('promise2', promise2);
}, 2000)

// promise1{<pending>}
// promise1{<pending>}
// time1
// time2
// promise1{<success>}
// promise1{<rejected>}